<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<c:set var="path" value="${pageContext.request.contextPath}"></c:set>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>流浪宠物救助系统</title>
    <link href="static/css/style.css" rel="stylesheet">
    <link href="static/css/bootstrap.min.css" rel="stylesheet">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <link href="static/css/IE8.css" rel="stylesheet">
    <![endif]-->
    <!-- layui使用的样式-->
    <link rel="stylesheet" href="${path}/admin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${path}/user/assets/css/amazeui.css"/>
    <link href="${path}/user/css/dlstyle.css" rel="stylesheet" type="text/css">
</head>

<body>
<jsp:include page="header.jsp"></jsp:include>


<div class="login-banner">
    <div class="login-main">
        <div class="login-box">
            <h3 class="title">登录流浪宠物救助系统</h3>
            <div class="clear"></div>
            <div class="login-form">
                <form>
                    <div class="user-phone">
                        <label for="loginName"><i class=" am-icon-mobile-phone am-icon-md"></i></label>
                        <input type="text" name="loginName" id="loginName" placeholder="请输入用户名或手机号">
                        <br>
                        <br>
                    </div>
                    <div class="user-pass">
                        <label for="password"><i class="am-icon-lock"></i></label>
                        <input type="password" name="password" id="password" placeholder="请输入密码">
                    </div>
                </form>
            </div>

            <div class="login-links">
                <a href="${path}/user/toResetPassword" class="am-fr">忘记密码</a>
                <a href="${path}/user/toRegister" class="zcnext am-fr am-btn-default">注册</a>
                <br/>
            </div>
            <div class="am-cf">
                <input type="button" id="login" value="登 录" class="am-btn am-btn-primary am-btn-sm">
            </div>

        </div>
    </div>
</div>


<jsp:include page="footer.jsp"></jsp:include>
</body>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<!-- layui的js-->
<script src="${path}/admin/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript">
    $(function () {
        layui.use(['laypage', 'layer'], function () {
            var laypage = layui.laypage, layer = layui.layer;
            $("#login").click(function () {
                if ($("#loginName").val() == "" || $("#loginName").val() == null) {
                    layer.tips("手机号不能为空", "#loginName")
                } else if ($("#password").val() == "" || $("#password").val() == null) {
                    layer.tips("密码不能为空", "#password")
                } else if ($("#loginName").val() != "" && $("#loginName").val() != null && $("#password").val() != "" && $("#password").val() != null) {
                    $.ajax({
                        url: "${path}/user/userLogin",
                        type: "post",
                        dataType: "json",
                        data: {
                            loginName: $("#loginName").val(),
                            password: $("#password").val()
                        }, success: function (data) {
                            if (data.code == 0) {
                                layer.msg(data.msg, {icon: 1, time: 2000}, function () {
                                    //登录成功跳转到前台首页
                                    location.href = "${path}/user/toIndex";
                                });
                            } else {
                                //登录失败、输出失败原因刷新页面
                                layer.msg(data.msg, {icon: 2, time: 2000}, function () {
                                    //location.reload();
                                });
                            }

                        }
                    });
                }
            });
        });
    });
</script>
</html>
